package org.example.curriculum_design_6_16.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.example.curriculum_design_6_16.entity.pojo.SocialServiceRule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 郑凯
* @description 针对表【social_service_rule】的数据库操作Mapper
* @createDate 2025-06-19 09:13:24
* @Entity org.example.curriculum_design_6_16.entity.pojo.SocialServiceRule
*/
@Mapper
public interface SocialServiceRuleMapper extends BaseMapper<SocialServiceRule> {

    /**
     * 根据规则键查找规则
     * @param ruleKey 规则键
     * @return 社会服务规则
     */
    @Select("SELECT * FROM social_service_rule WHERE rule_key = #{ruleKey} AND is_active = 1")
    SocialServiceRule findByRuleKey(@Param("ruleKey") String ruleKey);

    /**
     * 查找所有活跃的规则
     * @return 活跃规则列表
     */
    @Select("SELECT * FROM social_service_rule WHERE is_active = 1 ORDER BY rule_key")
    List<SocialServiceRule> findAllActiveRules();

}




